package com.drx.controller;

import com.drx.dojo.TabUser;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.serializer.RedisSerializer;
import org.springframework.data.redis.serializer.StringRedisSerializer;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
public class MyTest {
    @Autowired
    private RedisTemplate<Object,Object> redisTemplate;

    @RequestMapping("/test01")
    @ResponseBody
    public String  test01(){
        RedisSerializer stringSerializer = new StringRedisSerializer();

        redisTemplate.setKeySerializer(stringSerializer);
        redisTemplate.setValueSerializer(stringSerializer);
        redisTemplate.setHashKeySerializer(stringSerializer);
        redisTemplate.setHashValueSerializer(stringSerializer);

        TabUser tabUser=new TabUser();
        tabUser.setUid(1);
        tabUser.setPassword("132465");
        tabUser.setStudentnum(1831201025);

        redisTemplate.opsForList().rightPush("1A","上海");
        redisTemplate.opsForList().rightPush("1A","广州");
        redisTemplate.opsForList().rightPush("1A","重庆");
        return "成功";
    }
}
